package datastructure.ch03_linked.ch13_josephus;

import datastructure.ch03_linked.ch07_nodes.DoubleNode;
import datastructure.ch03_linked.ch08_interface_abstract.AbstractLinkedList;

/**
 * 约瑟夫问题
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class CircleOptLinked<E> extends AbstractLinkedList<E> {
    DoubleNode<E> first;
    DoubleNode<E> last;
    // 指向某个节点
    DoubleNode<E> currentNode;

    @Override
    public int indexOf(E element) {
        return 0;
    }

    @Override
    public void clear() {

    }

    @Override
    public void add(int index, E element) {

    }

    @Override
    public E remove(int index) {
        return null;
    }

    @Override
    public E set(int index, E element) {
        return null;
    }

    @Override
    public E get(int index) {
        return null;
    }

    /**
     * 重置环形链表，使currentNode指向first
     */
    public void reset() {
        currentNode = first;
    }

    /**
     * 让currentNode往后走一步，也就是currentNode = currentNode.next
     *
     * @return
     */
    public E next() {
        currentNode = currentNode.next;
        return currentNode.element;
    }

    /**
     * 删除currentNode指向的节点，删除成功后让currentNode指向下一个节点
     */
}
